package com.yqz.sys.controller;

import com.yqz.common.base.controller.BaseController;
import com.yqz.common.util.WebUtil;
import com.yqz.sys.form.CompPermissionForm;
import com.yqz.sys.query.CompPermissionQuery;
import com.yqz.sys.service.CompPermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("comp/perm")
public class CompPermissionController extends BaseController<CompPermissionQuery, CompPermissionForm> {

    @Autowired
    private CompPermissionService permissionService;

    public CompPermissionController(CompPermissionService permissionService) {
        super(permissionService);
    }

    @RequestMapping("userMenu.do")
    public Object getCurrentMenu(){
        return permissionService.currentMenu();
    }

    @RequestMapping("list.do")
    public Object list(CompPermissionQuery query){
        query.setCompId(WebUtil.getCurrentCompUser().getCompId());
        return permissionService.queryAll(query);
    }

    @RequestMapping("pIds.do")
    public Object compPermIds(@RequestParam("rId") Integer rId){
        return permissionService.pIdsByRole(rId);
    }

}
